POV-Ray : Newsgroups : povray.advanced-users : Animating lengthening splines : Re: Animating lengthening splines Server Time
28 Jul 2024 14:23:02 EDT (-0400)
  Re: Animating lengthening splines  
From: Chris B
Date: 16 Jun 2005 13:49:32
Message: <42b1bbac$1@news.povray.org>
Here's an adaptation that measures the length of the spline first:

camera { location <0,2,-2> look_at 0 }
light_source { <-5,30,-10> 1 }
#declare MySpline =
  spline {
    cubic_spline
    -.25, <0,0,-1>
    0.00, <1,0,0>
    0.25, <0,0,1>
    0.50, <-1,0,0>
    0.75, <0,0,-1>
    1.00, <1,0,0>
    1.25, <0,0,1>
  }


#declare Percentage = 43;

#local ctr = 0;
#local SplineLength = 0;
#local OldPoint = MySpline(0);
#while (ctr <= 1)
  #local SplineLength = SplineLength + vlength(MySpline(ctr)-OldPoint);
  #local OldPoint = MySpline(ctr);
  #local ctr = ctr + 0.0001;
#end


#local ctr = 0;
#local DistanceTraveled = 0;
#local OldPoint = MySpline(0);
#while (DistanceTraveled < Percentage*SplineLength/100)
  #local DistanceTraveled = DistanceTraveled +
vlength(MySpline(ctr)-OldPoint);
  #local OldPoint = MySpline(ctr);
  sphere {
    MySpline(ctr),.1
    pigment { rgb <1-ctr,ctr,0> }
  }
  #local ctr = ctr + 0.001;
#end




Chris B.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.